Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix format of a downloaded json file #1306

Merged

Conversation

Katarzyna-B
Copy link
Contributor

@Katarzyna-B Katarzyna-B commented Mar 27, 2023

Short description of the changes

  • fix a format of a downloaded file to be able to use for uploading back into the UI

Signed-off-by: katarzyna katarzyna@smaato.com

@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (590cf8c) 95.51% compared to head (bb302fc) 95.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1306      +/-   ##
==========================================
+ Coverage   95.51%   95.60%   +0.09%     
==========================================
  Files         244      244              
  Lines        7651     7653       +2     
  Branches     2006     2006              
==========================================
+ Hits         7308     7317       +9     
+ Misses        343      336       -7     
Impacted Files Coverage Δ
...components/SearchTracePage/SearchResults/index.tsx 86.15% <100.00%> (+0.43%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@yurishkuro yurishkuro changed the title ## Which problem is this PR solving? Fix format of a downloaded json file Mar 27, 2023
@@ -113,7 +113,7 @@ export class UnconnectedSearchResults extends React.PureComponent<SearchResultsP
};

onDownloadResultsClicked = () => {
const file = new Blob([JSON.stringify(this.props.rawTraces)], { type: 'application/json' });
const file = new Blob([`{"data":${JSON.stringify(this.props.rawTraces)}}`], { type: 'application/json' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test for this kind of behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- Resolves jaegertracing#663 - fix format of a downloaded json file

## Short description of the changes
- fix a format of a downloaded file to be able to use for uploading back into the UI

Signed-off-by: katarzyna <katarzyna@smaato.com>
@Katarzyna-B Katarzyna-B force-pushed the batch_download_of_traces_fix_format branch from 8ec45d7 to 04334d7 Compare March 28, 2023 14:55
const view = 'traces';
wrapper.setProps({ location: { search: `${otherSearch}&${searchParam}=${view}` } });

const download = wrapper.find(DownloadResults).prop('onDownloadResultsClicked');
download();
expect(URL.createObjectURL).toBeCalledTimes(1);
expect(URL.createObjectURL).toBeCalledWith(file);
expect(file.text).toBe(content);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this tests that the downloaded content is in this specific format, not that the specific format is what the rest of the UI expects. Besides this simple assert, I would prefer to call into the functionality that's normally invoked when Upload is executed, i.e. something that parses the uploaded results and transforms them into search results. Then we can assert that the search results are what we expect given this rawTraces input. This way the test will ensure that the download format is always what is expected by the upload, right now it does not really do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got your point.
I need to check/learn how I can do it in the best way.
I'm not sure if I have enough time to write such kind of the integration test before my vacation.
In the worst case I will try to do it in the middle of the April.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to clarify, I don't mean some elaborate integration test, simply calling an "upload" function that must exist somewhere in the code already, to validate the results / format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed my changes, where I refactor a little bit the code and I used now readJsonFile in a test. This method is used by the upload too.
If it is something still missing I can do it first in two weeks.
Have a great day.
Katarzyna

- Resolves jaegertracing#663 - fix format of a downloaded json file

## Short description of the changes
- fix a format of a downloaded file format to be able to use for uploading back into the UI

Signed-off-by: katarzyna <katarzyna@smaato.com>
@yurishkuro yurishkuro merged commit 15e8494 into jaegertracing:main Apr 10, 2023
Binrix pushed a commit to Binrix/jaeger-ui that referenced this pull request Apr 18, 2023
- Part of jaegertracing#663 - fix format of a downloaded json file

## Short description of the changes
- fix a format of a downloaded file to be able to use for uploading back
into the UI

Signed-off-by: katarzyna <katarzyna@smaato.com>

---------

Signed-off-by: katarzyna <katarzyna@smaato.com>
ramumanam pushed a commit to ramumanam/jaeger-ui that referenced this pull request Jun 6, 2023
- Part of jaegertracing#663 - fix format of a downloaded json file

## Short description of the changes
- fix a format of a downloaded file to be able to use for uploading back
into the UI

Signed-off-by: katarzyna <katarzyna@smaato.com>

---------

Signed-off-by: katarzyna <katarzyna@smaato.com>
Signed-off-by: RAMU MANAM <manam.ramu@uber.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants